package com.wengluobiancheng.demo01;

import java.net.InetAddress;
import java.net.UnknownHostException;

public class Demo01 {
    public static void main(String[] args) throws UnknownHostException {
        InetAddress add = InetAddress.getByName("LAPTOP-119HS1BC");
        String hostName = add.getHostName();
        System.out.println("主机名为" + hostName);
        String hostAddress = add.getHostAddress();
        System.out.println("IP为" + hostAddress);
    }
}
